Skip to content

feat(labctl): add transformation hook support for image sync#44

Merged
jmgilman merged 1 commit intomasterfrom
joshuagilman/hom-26-add-transformation-hook-support-to-labctl
Dec 29, 2025
Merged

feat(labctl): add transformation hook support for image sync#44
jmgilman merged 1 commit intomasterfrom
joshuagilman/hom-26-add-transformation-hook-support-to-labctl

Conversation

@jmgilman
Copy link
Collaborator

Summary

  • Add a new transform hook type that allows modifying files before upload
  • Transform hooks receive a copy of the file and modify it in-place
  • The transformed output becomes the upload source while checksum verification uses the input file (for caching)

Design choice: Implemented Option C (in-place modification) from the issue - simplest API for hook authors who just modify the file passed as the first argument.

Changes

  • Schema: Added Transform field to Hooks struct with same validation as preUpload hooks
  • Executor: Added RunTransformHooks() that creates a temp copy, runs hooks in sequence, returns transformed file path
  • Sync: Transform hooks run after decompression, before preUpload hooks

Example Usage

images:
  - name: talos-um760
    source:
      url: https://factory.talos.dev/image/...
      checksum: sha256:abc123
    destination: talos/um760.iso
    hooks:
      transform:
        - name: embed-config
          command: ./scripts/embed-talos-config.sh
          args: ["--config", "machine.yaml"]
          timeout: 10m

Closes HOM-26

Test plan

  • Unit tests for RunTransformHooks() covering:
    • No hooks returns empty result
    • Single hook modifies file in-place
    • Multiple hooks chain correctly
    • Hook failure returns error and cleans up temp files
    • Hook receives LABCTL_HOOK_CACHE environment variable
  • Manifest validation tests for transform hooks
  • Integration test verifying transformed content is uploaded
  • All existing tests continue to pass (just all)

🤖 Generated with Claude Code

Add a new `transform` hook type that allows modifying files before upload.
Transform hooks receive a copy of the file and modify it in-place, with
the transformed output becoming the upload source.

Key changes:
- Add Transform field to Hooks struct in manifest schema
- Add RunTransformHooks() method to hook executor
- Integrate transform hooks into sync pipeline (runs after decompression,
  before preUpload hooks)
- Checksum verification uses input file (for caching), upload uses output

Closes HOM-26

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@linear
Copy link

linear bot commented Dec 29, 2025

@jmgilman jmgilman merged commit b827f03 into master Dec 29, 2025
1 check passed
@jmgilman jmgilman deleted the joshuagilman/hom-26-add-transformation-hook-support-to-labctl branch December 29, 2025 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant